const Router = require('@koa/router')
// const controller = require('./controller')
// const guard = require('./middleware/guard.middleware')
const config = require('./config')

const router = new Router()

router.get('/', async ctx => {
    ctx.body = 'Hi!'
})

if (!config.isPrd()) {
    router.all('/do-test', async ctx => {
        const req = {
            query: ctx.query,
            body: ctx.request.body,
            headers: ctx.headers,
            method: ctx.method
        }
        console.log(req)
        ctx.success({ arr: [1, 2, 3, 4], req })
    })

    router.get('/session', async ctx => {
        ctx.session.view = ctx.session.view ? ++ctx.session.view : 1

        ctx.body = ctx.session
    })
}

module.exports = router
